package com.job.createType.builder.extend;

import java.math.BigDecimal;

/**
 * @Author 王博
 * @DateTime 2025-04-28 08:55
 */
public class Product {
    private String name;
    private BigDecimal price;
    private Double weight;

    private Product(String name, BigDecimal price, Double weight){
          this.name = name;
          this.price = price;
          this.weight = weight;
    }

    @Override
    public String toString() {
        return "Product{" +
                "name='" + name + '\'' +
                ", price=" + price +
                ", weight=" + weight +
                '}';
    }

    public static Builder builder(){
        return new Builder();
    }

    public static class Builder{
        private String name;
        private BigDecimal price;
        private Double weight;

        public Builder name(String name){
            this.name = name;
            return this;
        }

        public Builder price(BigDecimal price){
            this.price = price;
            return this;
        }

        public Builder weight(Double weight){
            this.weight = weight;
            return this;
        }

        public Product build(){
            return new Product(name, price, weight);
        }
    }
}
